<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="feedback" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{feedbackHome.managed ? 'Edit' : 'Add'} Feedback</f:facet>


            <s:decorate id="feedbackidField" template="layout/edit.xhtml">
                <ui:define name="label">Feedbackid</ui:define>
                <h:inputText id="feedbackid"
                       required="true"
                          value="#{feedbackHome.instance.feedbackid}"
                           size="29">
                    <a:support event="onblur" reRender="feedbackidField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>




            <s:decorate id="textField" template="layout/edit.xhtml">
                <ui:define name="label">Text</ui:define>
                <h:inputTextarea id="text"
                               cols="80"
                               rows="3"
                           required="true"
                              value="#{feedbackHome.instance.text}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{feedbackHome.persist}"
                       disabled="#{!feedbackHome.wired}"
                       rendered="#{!feedbackHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{feedbackHome.update}"
                       rendered="#{feedbackHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{feedbackHome.remove}"
                      immediate="true"
                       rendered="#{feedbackHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Feedback.xhtml"
                rendered="#{feedbackHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty feedbackFrom ? 'FeedbackList' : feedbackFrom}.xhtml"
                rendered="#{!feedbackHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Job">
    <div class="association" id="jobParent">

        <h:outputText value="There is no job associated with this feedback."
                   rendered="#{feedbackHome.instance.job == null}"/>

        <rich:dataTable var="_job"
                   value="#{feedbackHome.instance.job}"
                rendered="#{feedbackHome.instance.job != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="jobTable">
            <h:column>
                <f:facet name="header">Jobname</f:facet>
                <h:outputText value="#{_job.jobname}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{feedbackHome.instance.job != null ? 'changeParent' : 'selectParent'}" value="#{feedbackHome.instance.job != null ? 'Change' : 'Select'} job"
                       view="/JobList.xhtml">
                <f:param name="from" value="FeedbackEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Timeentry">
    <div class="association" id="timeentryParent">

        <h:outputText value="There is no timeentry associated with this feedback."
                   rendered="#{feedbackHome.instance.timeentry == null}"/>

        <rich:dataTable var="_timeentry"
                   value="#{feedbackHome.instance.timeentry}"
                rendered="#{feedbackHome.instance.timeentry != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="timeentryTable">
            <h:column>
                <f:facet name="header">Timeentryid</f:facet>
                <h:outputText value="#{_timeentry.timeentryid}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Job jobname</f:facet>
                <h:outputText value="#{_timeentry.job.jobname}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Person personid</f:facet>
                <h:outputText value="#{_timeentry.person.personid}">
                    <f:convertNumber/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Startdatetime</f:facet>
                <h:outputText value="#{_timeentry.startdatetime}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
            <h:column>
                <f:facet name="header">Enddatetime</f:facet>
                <h:outputText value="#{_timeentry.enddatetime}">
                    <s:convertDateTime type="date" dateStyle="short"/>
                </h:outputText>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{feedbackHome.instance.timeentry != null ? 'changeParent' : 'selectParent'}" value="#{feedbackHome.instance.timeentry != null ? 'Change' : 'Select'} timeentry"
                       view="/TimeentryList.xhtml">
                <f:param name="from" value="FeedbackEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
